home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tcl / dist6.3 / tclInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-10  |  31.5 KB  |  831 lines

  1. /*
  2.  * tclInt.h --
  3.  *
  4.  *    Declarations of things used internally by the Tcl interpreter.
  5.  *
  6.  * Copyright 1987-1991 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /user6/ouster/tcl/RCS/tclInt.h,v 1.67 92/02/10 08:39:17 ouster Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _TCLINT
  19. #define _TCLINT
  20.  
  21. /*
  22.  * Common include files needed by most of the Tcl source files are
  23.  * included here, so that system-dependent personalizations for the
  24.  * include files only have to be made in once place.  This results
  25.  * in a few extra includes, but greater modularity.  The order of
  26.  * the three groups of #includes is important.  For example, stdio.h
  27.  * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
  28.  * needed by stdlib.h in some configurations.
  29.  */
  30.  
  31. #include <stdio.h>
  32.  
  33. #ifndef _TCL
  34. #include "tcl.h"
  35. #endif
  36. #ifndef _TCLHASH
  37. #include "tclHash.h"
  38. #endif
  39. #ifndef _REGEXP
  40. #include "regexp.h"
  41. #endif
  42.  
  43. /*
  44.  * Macro to use instead of "void" for arguments that must have
  45.  * type "void *" in ANSI C;  maps them to type "char *" in
  46.  * non-ANSI systems.  This macro may be used in some of the include
  47.  * files below, which is why it is defined here.
  48.  */
  49.  
  50. #ifndef VOID
  51. #   ifdef __STDC__
  52. #       define VOID void
  53. #   else
  54. #       define VOID char
  55. #   endif
  56. #endif
  57.  
  58. #include <ctype.h>
  59. #include <stdlib.h>
  60. #include <string.h>
  61. #include <varargs.h>
  62.  
  63. /*
  64.  * At present (12/91) not all stdlib.h implementations declare strtod.
  65.  * The declaration below is here to ensure that it's declared, so that
  66.  * the compiler won't take the default approach of assuming it returns
  67.  * an int.  There's no ANSI prototype for it because there would end
  68.  * up being too many conflicts with slightly-different prototypes.
  69.  */
  70.  
  71. extern double strtod();
  72.  
  73. /*
  74.  *----------------------------------------------------------------
  75.  * Data structures related to variables.   These are used primarily
  76.  * in tclVar.c
  77.  *----------------------------------------------------------------
  78.  */
  79.  
  80. /*
  81.  * The following structure defines a variable trace, which is used to
  82.  * invoke a specific C procedure whenever certain operations are performed
  83.  * on a variable.
  84.  */
  85.  
  86. typedef struct VarTrace {
  87.     Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
  88.                  * by flags are performed on variable. */
  89.     ClientData clientData;    /* Argument to pass to proc. */
  90.     int flags;            /* What events the trace procedure is
  91.                  * interested in:  OR-ed combination of
  92.                  * TCL_TRACE_READS, TCL_TRACE_WRITES, and
  93.                  * TCL_TRACE_UNSETS. */
  94.     struct VarTrace *nextPtr;    /* Next in list of traces associated with
  95.                  * a particular variable. */
  96. } VarTrace;
  97.  
  98. /*
  99.  * When a variable trace is active (i.e. its associated procedure is
  100.  * executing), one of the following structures is linked into a list
  101.  * associated with the variable's interpreter.  The information in
  102.  * the structure is needed in order for Tcl to behave reasonably
  103.  * if traces are deleted while traces are active.
  104.  */
  105.  
  106. typedef struct ActiveVarTrace {
  107.     struct ActiveVarTrace *nextPtr;
  108.                 /* Next in list of all active variable
  109.                  * traces for the interpreter, or NULL
  110.                  * if no more. */
  111.     VarTrace *nextTracePtr;    /* Next trace to check after current
  112.                  * trace procedure returns;  if this
  113.                  * trace gets deleted, must update pointer
  114.                  * to avoid using free'd memory. */
  115. } ActiveVarTrace;
  116.  
  117. /*
  118.  * The following structure describes an enumerative search in progress on
  119.  * an array variable;  this are invoked with options to the "array"
  120.  * command.
  121.  */
  122.  
  123. typedef struct ArraySearch {
  124.     int id;            /* Integer id used to distinguish among
  125.                  * multiple concurrent searches for the
  126.                  * same array. */
  127.     struct Var *varPtr;        /* Pointer to array variable that's being
  128.                  * searched. */
  129.     Tcl_HashSearch search;    /* Info kept by the hash module about
  130.                  * progress through the array. */
  131.     Tcl_HashEntry *nextEntry;    /* Non-null means this is the next element
  132.                  * to be enumerated (it's leftover from
  133.                  * the Tcl_FirstHashEntry call or from
  134.                  * an "array anymore" command).  NULL
  135.                  * means must call Tcl_NextHashEntry
  136.                  * to get value to return. */
  137.     struct ArraySearch *nextPtr;/* Next in list of all active searches
  138.                  * for this variable, or NULL if this is
  139.                  * the last one. */
  140. } ArraySearch;
  141.  
  142. /*
  143.  * The structure below defines a variable, which associates a string name
  144.  * with a string value.  Pointers to these structures are kept as the
  145.  * values of hash table entries, and the name of each variable is stored
  146.  * in the hash entry.
  147.  */
  148.  
  149. typedef struct Var {
  150.     int valueLength;        /* Holds the number of non-null bytes
  151.                  * actually occupied by the variable's
  152.                  * current value in value.string (extra
  153.                  * space is sometimes left for expansion).
  154.                  * For array and global variables this is
  155.                  * meaningless. */
  156.     int valueSpace;        /* Total number of bytes of space allocated
  157.                  * at value. */
  158.     int upvarUses;        /* Counts number of times variable is
  159.                  * is referenced via global or upvar variables
  160.                  * (i.e. how many variables have "upvarPtr"
  161.                  * pointing to this variable).  Variable
  162.                  * can't be deleted until this count reaches
  163.                  * 0. */
  164.     VarTrace *tracePtr;        /* First in list of all traces set for this
  165.                  * variable. */
  166.     ArraySearch *searchPtr;    /* First in list of all searches active
  167.                  * for this variable, or NULL if none. */
  168.     int flags;            /* Miscellaneous bits of information about
  169.                  * variable.  See below for definitions. */
  170.     union {
  171.     char string[4];        /* String value of variable.  The actual
  172.                  * length of this field is given by the
  173.                  * valueSpace field above. */
  174.     Tcl_HashTable *tablePtr;/* For array variables, this points to
  175.                  * information about the hash table used
  176.                  * to implement the associative array. 
  177.                  * Points to malloc-ed data. */
  178.     Tcl_HashEntry *upvarPtr;
  179.                 /* If this is a global variable being
  180.                  * referred to in a procedure, or a variable
  181.                  * created by "upvar", this field points to
  182.                  * the hash table entry for the higher-level
  183.                  * variable. */
  184.     } value;            /* MUST BE LAST FIELD IN STRUCTURE!!! */
  185. } Var;
  186.  
  187. /*
  188.  * Flag bits for variables:
  189.  *
  190.  * VAR_ARRAY    -        1 means this is an array variable rather
  191.  *                than a scalar variable.
  192.  * VAR_UPVAR -             1 means this variable just contains a
  193.  *                pointer to another variable that has the
  194.  *                real value.  Variables like this come
  195.  *                about through the "upvar" and "global"
  196.  *                commands.
  197.  * VAR_UNDEFINED -        1 means that the variable is currently
  198.  *                undefined.  Undefined variables usually
  199.  *                go away completely, but if an undefined
  200.  *                variable has a trace on it, or if it is
  201.  *                a global variable being used by a procedure,
  202.  *                then it stays around even when undefined.
  203.  * VAR_ELEMENT_ACTIVE -        Used only in array variables;  1 means that
  204.  *                an element of the array is currently being
  205.  *                manipulated in some way, so that it isn't
  206.  *                safe to delete the whole array.
  207.  * VAR_TRACE_ACTIVE -        1 means that trace processing is currently
  208.  *                underway for a read or write access, so
  209.  *                new read or write accesses should not cause
  210.  *                trace procedures to be called and the
  211.  *                variable can't be deleted.
  212.  */
  213.  
  214. #define VAR_ARRAY        1
  215. #define VAR_UPVAR        2
  216. #define VAR_UNDEFINED        4
  217. #define VAR_ELEMENT_ACTIVE    0x10
  218. #define VAR_TRACE_ACTIVE    0x20
  219. #define VAR_SEARCHES_POSSIBLE    0x40
  220.  
  221. /*
  222.  *----------------------------------------------------------------
  223.  * Data structures related to procedures.   These are used primarily
  224.  * in tclProc.c
  225.  *----------------------------------------------------------------
  226.  */
  227.  
  228. /*
  229.  * The structure below defines an argument to a procedure, which
  230.  * consists of a name and an (optional) default value.
  231.  */
  232.  
  233. typedef struct Arg {
  234.     struct Arg *nextPtr;    /* Next argument for this procedure,
  235.                  * or NULL if this is the last argument. */
  236.     char *defValue;        /* Pointer to arg's default value, or NULL
  237.                  * if no default value. */
  238.     char name[4];        /* Name of argument starts here.  The name
  239.                  * is followed by space for the default,
  240.                  * if there is one.  The actual size of this
  241.                  * field will be as large as necessary to
  242.                  * hold both name and default value.  THIS
  243.                  * MUST BE THE LAST FIELD IN THE STRUCTURE!! */
  244. } Arg;
  245.  
  246. /*
  247.  * The structure below defines a command procedure, which consists of
  248.  * a collection of Tcl commands plus information about arguments and
  249.  * variables.
  250.  */
  251.  
  252. typedef struct Proc {
  253.     struct Interp *iPtr;    /* Interpreter for which this command
  254.                  * is defined. */
  255.     char *command;        /* Command that constitutes the body of
  256.                  * the procedure (dynamically allocated). */
  257.     Arg *argPtr;        /* Pointer to first of procedure's formal
  258.                  * arguments, or NULL if none. */
  259. } Proc;
  260.  
  261. /*
  262.  * The structure below defines a command trace.  This is used to allow Tcl
  263.  * clients to find out whenever a command is about to be executed.
  264.  */
  265.  
  266. typedef struct Trace {
  267.     int level;            /* Only trace commands at nesting level
  268.                  * less than or equal to this. */
  269.     Tcl_CmdTraceProc *proc;    /* Procedure to call to trace command. */
  270.     ClientData clientData;    /* Arbitrary value to pass to proc. */
  271.     struct Trace *nextPtr;    /* Next in list of traces for this interp. */
  272. } Trace;
  273.  
  274. /*
  275.  * The structure below defines a frame, which is a procedure invocation.
  276.  * These structures exist only while procedures are being executed, and
  277.  * provide a sort of call stack.
  278.  */
  279.  
  280. typedef struct CallFrame {
  281.     Tcl_HashTable varTable;    /* Hash table containing all of procedure's
  282.                  * local variables. */
  283.     int level;            /* Level of this procedure, for "uplevel"
  284.                  * purposes (i.e. corresponds to nesting of
  285.                  * callerVarPtr's, not callerPtr's).  1 means
  286.                  * outer-most procedure, 0 means top-level. */
  287.     int argc;            /* This and argv below describe name and
  288.                  * arguments for this procedure invocation. */
  289.     char **argv;        /* Array of arguments. */
  290.     struct CallFrame *callerPtr;
  291.                 /* Frame of procedure that invoked this one
  292.                  * (NULL if level == 1). */
  293.     struct CallFrame *callerVarPtr;
  294.                 /* Frame used by caller for accessing local
  295.                  * variables (same as callerPtr unless an
  296.                  * "uplevel" command was active in the
  297.                  * caller).  This field is used in the
  298.                  * implementation of "uplevel". */
  299. } CallFrame;
  300.  
  301. /*
  302.  * The structure below defines one history event (a previously-executed
  303.  * command that can be re-executed in whole or in part).
  304.  */
  305.  
  306. typedef struct {
  307.     char *command;        /* String containing previously-executed
  308.                  * command. */
  309.     int bytesAvl;        /* Total # of bytes available at *event (not
  310.                  * all are necessarily in use now). */
  311. } HistoryEvent;
  312.  
  313. /*
  314.  *----------------------------------------------------------------
  315.  * Data structures related to history.   These are used primarily
  316.  * in tclHistory.c
  317.  *----------------------------------------------------------------
  318.  */
  319.  
  320. /*
  321.  * The structure below defines a pending revision to the most recent
  322.  * history event.  Changes are linked together into a list and applied
  323.  * during the next call to Tcl_RecordHistory.  See the comments at the
  324.  * beginning of tclHistory.c for information on revisions.
  325.  */
  326.  
  327. typedef struct HistoryRev {
  328.     int firstIndex;        /* Index of the first byte to replace in
  329.                  * current history event. */
  330.     int lastIndex;        /* Index of last byte to replace in
  331.                  * current history event. */
  332.     int newSize;        /* Number of bytes in newBytes. */
  333.     char *newBytes;        /* Replacement for the range given by
  334.                  * firstIndex and lastIndex. */
  335.     struct HistoryRev *nextPtr;    /* Next in chain of revisions to apply, or
  336.                  * NULL for end of list. */
  337. } HistoryRev;
  338.  
  339. /*
  340.  *----------------------------------------------------------------
  341.  * Data structures related to files.  These are used primarily in
  342.  * tclUnixUtil.c and tclUnixAZ.c.
  343.  *----------------------------------------------------------------
  344.  */
  345.  
  346. /*
  347.  * The data structure below defines an open file (or connection to
  348.  * a process pipeline) as returned by the "open" command.
  349.  */
  350.  
  351. typedef struct OpenFile {
  352.     FILE *f;            /* Stdio file to use for reading and/or
  353.                  * writing. */
  354.     FILE *f2;            /* Normally NULL.  In the special case of
  355.                  * a command pipeline with pipes for both
  356.                  * input and output, this is a stdio file
  357.                  * to use for writing to the pipeline. */
  358.     int readable;        /* Non-zero means file may be read. */
  359.     int writable;        /* Non-zero means file may be written. */
  360.     int numPids;        /* If this is a connection to a process
  361.                  * pipeline, gives number of processes
  362.                  * in pidPtr array below;  otherwise it
  363.                  * is 0. */
  364.     int *pidPtr;        /* Pointer to malloc-ed array of child
  365.                  * process ids (numPids of them), or NULL
  366.                  * if this isn't a connection to a process
  367.                  * pipeline. */
  368.     int errorId;        /* File id of file that receives error
  369.                  * output from pipeline.  -1 means not
  370.                  * used (i.e. this is a normal file). */
  371. } OpenFile;
  372.  
  373. /*
  374.  *----------------------------------------------------------------
  375.  * This structure defines an interpreter, which is a collection of
  376.  * commands plus other state information related to interpreting
  377.  * commands, such as variable storage.  Primary responsibility for
  378.  * this data structure is in tclBasic.c, but almost every Tcl
  379.  * source file uses something in here.
  380.  *----------------------------------------------------------------
  381.  */
  382.  
  383. typedef struct Command {
  384.     Tcl_CmdProc *proc;        /* Procedure to process command. */
  385.     ClientData clientData;    /* Arbitrary value to pass to proc. */
  386.     Tcl_CmdDeleteProc *deleteProc;
  387.                 /* Procedure to invoke when deleting
  388.                  * command. */
  389. } Command;
  390.  
  391. #define CMD_SIZE(nameLength) ((unsigned) sizeof(Command) + nameLength - 3)
  392.  
  393. typedef struct Interp {
  394.  
  395.     /*
  396.      * Note:  the first three fields must match exactly the fields in
  397.      * a Tcl_Interp struct (see tcl.h).  If you change one, be sure to
  398.      * change the other.
  399.      */
  400.  
  401.     char *result;        /* Points to result returned by last
  402.                  * command. */
  403.     Tcl_FreeProc *freeProc;    /* Zero means result is statically allocated.
  404.                  * If non-zero, gives address of procedure
  405.                  * to invoke to free the result.  Must be
  406.                  * freed by Tcl_Eval before executing next
  407.                  * command. */
  408.     int errorLine;        /* When TCL_ERROR is returned, this gives
  409.                  * the line number within the command where
  410.                  * the error occurred (1 means first line). */
  411.     Tcl_HashTable commandTable;    /* Contains all of the commands currently
  412.                  * registered in this interpreter.  Indexed
  413.                  * by strings; values have type (Command *). */
  414.  
  415.     /*
  416.      * Information related to procedures and variables.  See tclProc.c
  417.      * and tclvar.c for usage.
  418.      */
  419.  
  420.     Tcl_HashTable globalTable;    /* Contains all global variables for
  421.                  * interpreter. */
  422.     int numLevels;        /* Keeps track of how many nested calls to
  423.                  * Tcl_Eval are in progress for this
  424.                  * interpreter.  It's used to delay deletion
  425.                  * of the table until all Tcl_Eval invocations
  426.                  * are completed. */
  427.     CallFrame *framePtr;    /* If a procedure is being executed, this
  428.                  * points to the call frame for the current
  429.                  * procedure (most recently-called).  NULL
  430.                  * means no procedure is active. */
  431.     CallFrame *varFramePtr;    /* Points to the call frame whose variables
  432.                  * are currently in use (same as framePtr
  433.                  * unless an "uplevel" command is being
  434.                  * executed).  NULL means no procedure is
  435.                  * active or "uplevel 0" is being exec'ed. */
  436.     ActiveVarTrace *activeTracePtr;
  437.                 /* First in list of active traces for interp,
  438.                  * or NULL if no active traces. */
  439.  
  440.     /*
  441.      * Information related to history:
  442.      */
  443.  
  444.     int numEvents;        /* Number of previously-executed commands
  445.                  * to retain. */
  446.     HistoryEvent *events;    /* Array containing numEvents entries
  447.                  * (dynamically allocated). */
  448.     int curEvent;        /* Index into events of place where current
  449.                  * (or most recent) command is recorded. */
  450.     int curEventNum;        /* Event number associated with the slot
  451.                  * given by curEvent. */
  452.     HistoryRev *revPtr;        /* First in list of pending revisions. */
  453.     char *historyFirst;        /* First char. of current command executed
  454.                  * from history module or NULL if none. */
  455.     int revDisables;        /* 0 means history revision OK;  > 0 gives
  456.                  * a count of number of times revision has
  457.                  * been disabled. */
  458.     char *evalFirst;        /* If TCL_RECORD_BOUNDS flag set, Tcl_Eval
  459.                  * sets this field to point to the first
  460.                  * char. of text from which the current
  461.                  * command came.  Otherwise Tcl_Eval sets
  462.                  * this to NULL. */
  463.     char *evalLast;        /* Similar to evalFirst, except points to
  464.                  * last character of current command. */
  465.  
  466.     /*
  467.      * Information used by Tcl_AppendResult to keep track of partial
  468.      * results.  See Tcl_AppendResult code for details.
  469.      */
  470.  
  471.     char *appendResult;        /* Storage space for results generated
  472.                  * by Tcl_AppendResult.  Malloc-ed.  NULL
  473.                  * means not yet allocated. */
  474.     int appendAvl;        /* Total amount of space available at
  475.                  * partialResult. */
  476.     int appendUsed;        /* Number of non-null bytes currently
  477.                  * stored at partialResult. */
  478.  
  479.     /*
  480.      * Information related to files.  See tclUnixAZ.c and tclUnixUtil.c
  481.      * for details.
  482.      */
  483.  
  484.     int numFiles;        /* Number of entries in filePtrArray
  485.                  * below.  0 means array hasn't been
  486.                  * created yet. */
  487.     OpenFile **filePtrArray;    /* Pointer to malloc-ed array of pointers
  488.                  * to information about open files.  Entry
  489.                  * N corresponds to the file with fileno N.
  490.                  * If an entry is NULL then the corresponding
  491.                  * file isn't open.  If filePtrArray is NULL
  492.                  * it means no files have been used, so even
  493.                  * stdin/stdout/stderr entries haven't been
  494.                  * setup yet. */
  495.     /*
  496.      * A cache of compiled regular expressions.  See TclCompileRegexp
  497.      * in tclUtil.c for details.
  498.      */
  499.  
  500. #define NUM_REGEXPS 5
  501.     char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled
  502.                  * regular expression patterns.  NULL
  503.                  * means that this slot isn't used.
  504.                  * Malloc-ed. */
  505.     int patLengths[NUM_REGEXPS];/* Number of non-null characters in
  506.                  * corresponding entry in patterns. */
  507.     regexp *regexps[NUM_REGEXPS];
  508.                 /* Compiled forms of above strings.  Also
  509.                  * malloc-ed, or NULL if not in use yet. */
  510.  
  511.  
  512.     /*
  513.      * Miscellaneous information:
  514.      */
  515.  
  516.     int cmdCount;        /* Total number of times a command procedure
  517.                  * has been called for this interpreter. */
  518.     int noEval;            /* Non-zero means no commands should actually
  519.                  * be executed:  just parse only.  Used in
  520.                  * expressions when the result is already
  521.                  * determined. */
  522.     char *scriptFile;        /* NULL means there is no nested source
  523.                  * command active;  otherwise this points to
  524.                  * the name of the file being sourced (it's
  525.                  * not malloc-ed:  it points to an argument
  526.                  * to Tcl_EvalFile. */
  527.     int flags;            /* Various flag bits.  See below. */
  528.     Trace *tracePtr;        /* List of traces for this interpreter. */
  529.     char resultSpace[TCL_RESULT_SIZE+1];
  530.                 /* Static space for storing small results. */
  531. } Interp;
  532.  
  533. /*
  534.  * Flag bits for Interp structures:
  535.  *
  536.  * DELETED:        Non-zero means the interpreter has been deleted:
  537.  *            don't process any more commands for it, and destroy
  538.  *            the structure as soon as all nested invocations of
  539.  *            Tcl_Eval are done.
  540.  * ERR_IN_PROGRESS:    Non-zero means an error unwind is already in progress.
  541.  *            Zero means a command proc has been invoked since last
  542.  *            error occured.
  543.  * ERR_ALREADY_LOGGED:    Non-zero means information has already been logged
  544.  *            in $errorInfo for the current Tcl_Eval instance,
  545.  *            so Tcl_Eval needn't log it (used to implement the
  546.  *            "error message log" command).
  547.  * ERROR_CODE_SET:    Non-zero means that Tcl_SetErrorCode has been
  548.  *            called to record information for the current
  549.  *            error.  Zero means Tcl_Eval must clear the
  550.  *            errorCode variable if an error is returned.
  551.  */
  552.  
  553. #define DELETED            1
  554. #define ERR_IN_PROGRESS        2
  555. #define ERR_ALREADY_LOGGED    4
  556. #define ERROR_CODE_SET        8
  557.  
  558. /*
  559.  *----------------------------------------------------------------
  560.  * Data structures related to command parsing.   These are used in
  561.  * tclParse.c and its clients.
  562.  *----------------------------------------------------------------
  563.  */
  564.  
  565. /*
  566.  * The following data structure is used by various parsing procedures
  567.  * to hold information about where to store the results of parsing
  568.  * (e.g. the substituted contents of a quoted argument, or the result
  569.  * of a nested command).  At any given time, the space available
  570.  * for output is fixed, but a procedure may be called to expand the
  571.  * space available if the current space runs out.
  572.  */
  573.  
  574. typedef struct ParseValue {
  575.     char *buffer;        /* Address of first character in
  576.                  * output buffer. */
  577.     char *next;            /* Place to store next character in
  578.                  * output buffer. */
  579.     char *end;            /* Address of the last usable character
  580.                  * in the buffer. */
  581.     void (*expandProc) _ANSI_ARGS_((struct ParseValue *pvPtr, int needed));
  582.                 /* Procedure to call when space runs out;
  583.                  * it will make more space. */
  584.     ClientData clientData;    /* Arbitrary information for use of
  585.                  * expandProc. */
  586. } ParseValue;
  587.  
  588. /*
  589.  * A table used to classify input characters to assist in parsing
  590.  * Tcl commands.  The table should be indexed with a signed character
  591.  * using the CHAR_TYPE macro.  The character may have a negative
  592.  * value.
  593.  */
  594.  
  595. extern char tclTypeTable[];
  596. #define CHAR_TYPE(c) (tclTypeTable+128)[c]
  597.  
  598. /*
  599.  * Possible values returned by CHAR_TYPE:
  600.  *
  601.  * TCL_NORMAL -        All characters that don't have special significance
  602.  *            to the Tcl language.
  603.  * TCL_SPACE -        Character is space, tab, or return.
  604.  * TCL_COMMAND_END -    Character is newline or null or semicolon or
  605.  *            close-bracket.
  606.  * TCL_QUOTE -        Character is a double-quote.
  607.  * TCL_OPEN_BRACKET -    Character is a "[".
  608.  * TCL_OPEN_BRACE -    Character is a "{".
  609.  * TCL_CLOSE_BRACE -    Character is a "}".
  610.  * TCL_BACKSLASH -    Character is a "\".
  611.  * TCL_DOLLAR -        Character is a "$".
  612.  */
  613.  
  614. #define TCL_NORMAL        0
  615. #define TCL_SPACE        1
  616. #define TCL_COMMAND_END        2
  617. #define TCL_QUOTE        3
  618. #define TCL_OPEN_BRACKET    4
  619. #define TCL_OPEN_BRACE        5
  620. #define TCL_CLOSE_BRACE        6
  621. #define TCL_BACKSLASH        7
  622. #define TCL_DOLLAR        8
  623.  
  624. /*
  625.  * Additional flags passed to Tcl_Eval.  See tcl.h for other flags to
  626.  * Tcl_Eval;  these ones are only used internally by Tcl.
  627.  *
  628.  * TCL_RECORD_BOUNDS    Tells Tcl_Eval to record information in the
  629.  *            evalFirst and evalLast fields for each command
  630.  *            executed directly from the string (top-level
  631.  *            commands and those from command substitution).
  632.  */
  633.  
  634. #define TCL_RECORD_BOUNDS    0x100
  635.  
  636. /*
  637.  * Maximum number of levels of nesting permitted in Tcl commands.
  638.  */
  639.  
  640. #define MAX_NESTING_DEPTH    100
  641.  
  642. /*
  643.  * Variables shared among Tcl modules but not used by the outside
  644.  * world:
  645.  */
  646.  
  647. extern char *        tclRegexpError;
  648.  
  649. /*
  650.  *----------------------------------------------------------------
  651.  * Procedures shared among Tcl modules but not used by the outside
  652.  * world:
  653.  *----------------------------------------------------------------
  654.  */
  655.  
  656. extern void        panic();
  657. extern regexp *        TclCompileRegexp _ANSI_ARGS_((Tcl_Interp *interp,
  658.                 char *string));
  659. extern void        TclCopyAndCollapse _ANSI_ARGS_((int count, char *src,
  660.                 char *dst));
  661. extern void        TclDeleteVars _ANSI_ARGS_((Interp *iPtr,
  662.                 Tcl_HashTable *tablePtr));
  663. extern void        TclExpandParseValue _ANSI_ARGS_((ParseValue *pvPtr,
  664.                 int needed));
  665. extern int        TclFindElement _ANSI_ARGS_((Tcl_Interp *interp,
  666.                 char *list, char **elementPtr, char **nextPtr,
  667.                 int *sizePtr, int *bracePtr));
  668. extern Proc *        TclFindProc _ANSI_ARGS_((Interp *iPtr,
  669.                 char *procName));
  670. extern int        TclGetFrame _ANSI_ARGS_((Tcl_Interp *interp,
  671.                 char *string, CallFrame **framePtrPtr));
  672. extern int        TclGetListIndex _ANSI_ARGS_((Tcl_Interp *interp,
  673.                 char *string, int *indexPtr));
  674. extern int        TclGetOpenFile _ANSI_ARGS_((Tcl_Interp *interp,
  675.                 char *string, OpenFile **filePtrPtr));
  676. extern Proc *        TclIsProc _ANSI_ARGS_((Command *cmdPtr));
  677. extern void        TclMakeFileTable _ANSI_ARGS_((Interp *iPtr,
  678.                 int index));
  679. extern int        TclParseBraces _ANSI_ARGS_((Tcl_Interp *interp,
  680.                 char *string, char **termPtr, ParseValue *pvPtr));
  681. extern int        TclParseNestedCmd _ANSI_ARGS_((Tcl_Interp *interp,
  682.                 char *string, int flags, char **termPtr,
  683.                 ParseValue *pvPtr));
  684. extern int        TclParseQuotes _ANSI_ARGS_((Tcl_Interp *interp,
  685.                 char *string, int termChar, int flags,
  686.                 char **termPtr, ParseValue *pvPtr));
  687. extern int        TclParseWords _ANSI_ARGS_((Tcl_Interp *interp,
  688.                 char *string, int flags, int maxWords,
  689.                 char **termPtr, int *argcPtr, char **argv,
  690.                 ParseValue *pvPtr));
  691. extern void        TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp));
  692. extern char *        TclWordEnd _ANSI_ARGS_((char *start, int nested));
  693.  
  694. /*
  695.  *----------------------------------------------------------------
  696.  * Command procedures in the generic core:
  697.  *----------------------------------------------------------------
  698.  */
  699.  
  700. extern int    Tcl_AppendCmd _ANSI_ARGS_((ClientData clientData,
  701.             Tcl_Interp *interp, int argc, char **argv));
  702. extern int    Tcl_ArrayCmd _ANSI_ARGS_((ClientData clientData,
  703.             Tcl_Interp *interp, int argc, char **argv));
  704. extern int    Tcl_BreakCmd _ANSI_ARGS_((ClientData clientData,
  705.             Tcl_Interp *interp, int argc, char **argv));
  706. extern int    Tcl_CaseCmd _ANSI_ARGS_((ClientData clientData,
  707.             Tcl_Interp *interp, int argc, char **argv));
  708. extern int    Tcl_CatchCmd _ANSI_ARGS_((ClientData clientData,
  709.             Tcl_Interp *interp, int argc, char **argv));
  710. extern int    Tcl_ConcatCmd _ANSI_ARGS_((ClientData clientData,
  711.             Tcl_Interp *interp, int argc, char **argv));
  712. extern int    Tcl_ContinueCmd _ANSI_ARGS_((ClientData clientData,
  713.             Tcl_Interp *interp, int argc, char **argv));
  714. extern int    Tcl_ErrorCmd _ANSI_ARGS_((ClientData clientData,
  715.             Tcl_Interp *interp, int argc, char **argv));
  716. extern int    Tcl_EvalCmd _ANSI_ARGS_((ClientData clientData,
  717.             Tcl_Interp *interp, int argc, char **argv));
  718. extern int    Tcl_ExprCmd _ANSI_ARGS_((ClientData clientData,
  719.             Tcl_Interp *interp, int argc, char **argv));
  720. extern int    Tcl_ForCmd _ANSI_ARGS_((ClientData clientData,
  721.             Tcl_Interp *interp, int argc, char **argv));
  722. extern int    Tcl_ForeachCmd _ANSI_ARGS_((ClientData clientData,
  723.             Tcl_Interp *interp, int argc, char **argv));
  724. extern int    Tcl_FormatCmd _ANSI_ARGS_((ClientData clientData,
  725.             Tcl_Interp *interp, int argc, char **argv));
  726. extern int    Tcl_GlobalCmd _ANSI_ARGS_((ClientData clientData,
  727.             Tcl_Interp *interp, int argc, char **argv));
  728. extern int    Tcl_HistoryCmd _ANSI_ARGS_((ClientData clientData,
  729.             Tcl_Interp *interp, int argc, char **argv));
  730. extern int    Tcl_IfCmd _ANSI_ARGS_((ClientData clientData,
  731.             Tcl_Interp *interp, int argc, char **argv));
  732. extern int    Tcl_IncrCmd _ANSI_ARGS_((ClientData clientData,
  733.             Tcl_Interp *interp, int argc, char **argv));
  734. extern int    Tcl_InfoCmd _ANSI_ARGS_((ClientData clientData,
  735.             Tcl_Interp *interp, int argc, char **argv));
  736. extern int    Tcl_JoinCmd _ANSI_ARGS_((ClientData clientData,
  737.             Tcl_Interp *interp, int argc, char **argv));
  738. extern int    Tcl_LappendCmd _ANSI_ARGS_((ClientData clientData,
  739.             Tcl_Interp *interp, int argc, char **argv));
  740. extern int    Tcl_LindexCmd _ANSI_ARGS_((ClientData clientData,
  741.             Tcl_Interp *interp, int argc, char **argv));
  742. extern int    Tcl_LinsertCmd _ANSI_ARGS_((ClientData clientData,
  743.             Tcl_Interp *interp, int argc, char **argv));
  744. extern int    Tcl_LlengthCmd _ANSI_ARGS_((ClientData clientData,
  745.             Tcl_Interp *interp, int argc, char **argv));
  746. extern int    Tcl_ListCmd _ANSI_ARGS_((ClientData clientData,
  747.             Tcl_Interp *interp, int argc, char **argv));
  748. extern int    Tcl_LrangeCmd _ANSI_ARGS_((ClientData clientData,
  749.             Tcl_Interp *interp, int argc, char **argv));
  750. extern int    Tcl_LreplaceCmd _ANSI_ARGS_((ClientData clientData,
  751.             Tcl_Interp *interp, int argc, char **argv));
  752. extern int    Tcl_LsearchCmd _ANSI_ARGS_((ClientData clientData,
  753.             Tcl_Interp *interp, int argc, char **argv));
  754. extern int    Tcl_LsortCmd _ANSI_ARGS_((ClientData clientData,
  755.             Tcl_Interp *interp, int argc, char **argv));
  756. extern int    Tcl_ProcCmd _ANSI_ARGS_((ClientData clientData,
  757.             Tcl_Interp *interp, int argc, char **argv));
  758. extern int    Tcl_RegexpCmd _ANSI_ARGS_((ClientData clientData,
  759.             Tcl_Interp *interp, int argc, char **argv));
  760. extern int    Tcl_RegsubCmd _ANSI_ARGS_((ClientData clientData,
  761.             Tcl_Interp *interp, int argc, char **argv));
  762. extern int    Tcl_RenameCmd _ANSI_ARGS_((ClientData clientData,
  763.             Tcl_Interp *interp, int argc, char **argv));
  764. extern int    Tcl_ReturnCmd _ANSI_ARGS_((ClientData clientData,
  765.             Tcl_Interp *interp, int argc, char **argv));
  766. extern int    Tcl_ScanCmd _ANSI_ARGS_((ClientData clientData,
  767.             Tcl_Interp *interp, int argc, char **argv));
  768. extern int    Tcl_SetCmd _ANSI_ARGS_((ClientData clientData,
  769.             Tcl_Interp *interp, int argc, char **argv));
  770. extern int    Tcl_SplitCmd _ANSI_ARGS_((ClientData clientData,
  771.             Tcl_Interp *interp, int argc, char **argv));
  772. extern int    Tcl_StringCmd _ANSI_ARGS_((ClientData clientData,
  773.             Tcl_Interp *interp, int argc, char **argv));
  774. extern int    Tcl_TraceCmd _ANSI_ARGS_((ClientData clientData,
  775.             Tcl_Interp *interp, int argc, char **argv));
  776. extern int    Tcl_UnsetCmd _ANSI_ARGS_((ClientData clientData,
  777.             Tcl_Interp *interp, int argc, char **argv));
  778. extern int    Tcl_UplevelCmd _ANSI_ARGS_((ClientData clientData,
  779.             Tcl_Interp *interp, int argc, char **argv));
  780. extern int    Tcl_UpvarCmd _ANSI_ARGS_((ClientData clientData,
  781.             Tcl_Interp *interp, int argc, char **argv));
  782. extern int    Tcl_WhileCmd _ANSI_ARGS_((ClientData clientData,
  783.             Tcl_Interp *interp, int argc, char **argv));
  784. extern int    Tcl_Cmd _ANSI_ARGS_((ClientData clientData,
  785.             Tcl_Interp *interp, int argc, char **argv));
  786. extern int    Tcl_Cmd _ANSI_ARGS_((ClientData clientData,
  787.             Tcl_Interp *interp, int argc, char **argv));
  788.  
  789. /*
  790.  *----------------------------------------------------------------
  791.  * Command procedures in the UNIX core:
  792.  *----------------------------------------------------------------
  793.  */
  794.  
  795. extern int    Tcl_CdCmd _ANSI_ARGS_((ClientData clientData,
  796.             Tcl_Interp *interp, int argc, char **argv));
  797. extern int    Tcl_CloseCmd _ANSI_ARGS_((ClientData clientData,
  798.             Tcl_Interp *interp, int argc, char **argv));
  799. extern int    Tcl_EofCmd _ANSI_ARGS_((ClientData clientData,
  800.             Tcl_Interp *interp, int argc, char **argv));
  801. extern int    Tcl_ExecCmd _ANSI_ARGS_((ClientData clientData,
  802.             Tcl_Interp *interp, int argc, char **argv));
  803. extern int    Tcl_ExitCmd _ANSI_ARGS_((ClientData clientData,
  804.             Tcl_Interp *interp, int argc, char **argv));
  805. extern int    Tcl_FileCmd _ANSI_ARGS_((ClientData clientData,
  806.             Tcl_Interp *interp, int argc, char **argv));
  807. extern int    Tcl_FlushCmd _ANSI_ARGS_((ClientData clientData,
  808.             Tcl_Interp *interp, int argc, char **argv));
  809. extern int    Tcl_GetsCmd _ANSI_ARGS_((ClientData clientData,
  810.             Tcl_Interp *interp, int argc, char **argv));
  811. extern int    Tcl_GlobCmd _ANSI_ARGS_((ClientData clientData,
  812.             Tcl_Interp *interp, int argc, char **argv));
  813. extern int    Tcl_OpenCmd _ANSI_ARGS_((ClientData clientData,
  814.             Tcl_Interp *interp, int argc, char **argv));
  815. extern int    Tcl_PutsCmd _ANSI_ARGS_((ClientData clientData,
  816.             Tcl_Interp *interp, int argc, char **argv));
  817. extern int    Tcl_PwdCmd _ANSI_ARGS_((ClientData clientData,
  818.             Tcl_Interp *interp, int argc, char **argv));
  819. extern int    Tcl_ReadCmd _ANSI_ARGS_((ClientData clientData,
  820.             Tcl_Interp *interp, int argc, char **argv));
  821. extern int    Tcl_SeekCmd _ANSI_ARGS_((ClientData clientData,
  822.             Tcl_Interp *interp, int argc, char **argv));
  823. extern int    Tcl_SourceCmd _ANSI_ARGS_((ClientData clientData,
  824.             Tcl_Interp *interp, int argc, char **argv));
  825. extern int    Tcl_TellCmd _ANSI_ARGS_((ClientData clientData,
  826.             Tcl_Interp *interp, int argc, char **argv));
  827. extern int    Tcl_TimeCmd _ANSI_ARGS_((ClientData clientData,
  828.             Tcl_Interp *interp, int argc, char **argv));
  829.  
  830. #endif /* _TCLINT */
  831.